<html>
	<head>
		<title>info tab测试</title>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<!-- script type="text/javascript" src="__PUBLIC__/js/jquery-1.10.2.js"></script //-->
		<script type="text/javascript" src="__PUBLIC__/js/jquery.cookie.js"></script>
		<script type="text/javascript" >
		
		jQuery.fn.floatdiv=function(location){
	//ie6要隐藏纵向滚动条
	var isIE6=false;
	if($.browser.msie && $.browser.version=="6.0"){
		$("html").css("overflow-x","auto").css("overflow-y","hidden");
		isIE6=true;
	};
	$("body").css({margin:"0px",padding:"0 10px 0 10px",
		border:"0px",
		height:"100%",
		overflow:"auto"
	});
	return this.each(function(){
		var loc;//层的绝对定位位置
		if(location==undefined || location.constructor == String){
			switch(location){
				case("rightbottom")://右下角
					loc={right:"0px",bottom:"0px"};
					break;
				case("leftbottom")://左下角
					loc={left:"0px",bottom:"0px"};
					break;	
				case("lefttop")://左上角
					loc={left:"0px",top:"0px"};
					break;
				case("righttop")://右上角
					loc={right:"0px",top:"0px"};
					break;
				case("middle")://居中
					var l=0;//居左
					var t=0;//居上
					var windowWidth,windowHeight;//窗口的高和宽
					//取得窗口的高和宽
					if (self.innerHeight) {
						windowWidth=self.innerWidth;
						windowHeight=self.innerHeight;
					}else if (document.documentElement&&document.documentElement.clientHeight) {
						windowWidth=document.documentElement.clientWidth;
						windowHeight=document.documentElement.clientHeight;
					} else if (document.body) {
						windowWidth=document.body.clientWidth;
						windowHeight=document.body.clientHeight;
					}
					l=windowWidth/2-$(this).width()/2;
					t=windowHeight/2-$(this).height()/2;
					loc={left:l+"px",top:t+"px"};
					break;
				default://默认为右下角
					loc={right:"0px",bottom:"0px"};
					break;
			}
		}else{
			loc=location;
		}
		$(this).css("z-index","9999").css(loc).css("position","fixed");
		if(isIE6){
			if(loc.right!=undefined){
				//2008-4-1修改：当自定义right位置时无效，这里加上一个判断
				//有值时就不设置，无值时要加18px已修正层位置
				if($(this).css("right")==null || $(this).css("right")==""){
					$(this).css("right","18px");
				}
			}
			$(this).css("position","absolute");
		}
	});
};

			var max_lines = 50;
			var n_tab1 = 0;
			var n_tab2 = 0;
			var n_tab3 = 0;

			var n_tab1id = 0;
			var n_tab2id = 0;
			var n_tab3id = 0;

			function addline(obj, argvs, url) {
				var args = argvs.length;

				var content = obj.children('table').html();
				content += "<tr>";
				for (var i = 0; i < args; i++){
					content += "<td><a href='" + url + "'>" + argvs[i] + "</a></td>";
				}
				content += "</tr>";
				var content = obj.children('table').html(content);

			}

			function delline(obj, count) {
				obj.each(function() {
					$(this).children('tbody').each(function() {
						var lines = $(this).children('tr');
						if (lines.length == 0)
							return;
						var times = 0;
						var i = 0;
						lines.each(function() {
							if ( times < count && i != 0 ) {
								$(this).remove();
								times ++;
								count -= 1;
							}
							i += 1;
						});
					});
				});
			}

			function infocheck() {
				getNews();
				$.getJSON("__APP__/admin/getEmergInfo",
						{
							orderid: n_tab1id,
							messageid: n_tab2id,
							orderlistid: n_tab3id
						},
						function(data) {
							$.each(data, function(k, v) {
								var srcurl = "__APP__/";
								if (k == 'order') {
									$.each(v, function(kk, vv) {
										n_tab1id = vv.id;
										vv.type = (vv.type == 'food' )? '点餐' : '购物';
										var arr = [vv.roomid, vv.ordernum, vv.type, vv.otime];
										var gotourl = srcurl +
"diancan/showdetail?rname=" + vv.roomid + "&ordernum=" + vv.ordernum + "&ordertype=" +
vv.type;
										if (n_tab1 <= max_lines) {
											addline($("#tab1"), arr, gotourl);
											n_tab1 += 1;
										} else {
											delline($("#tab1 table"), 1);
											n_tab1 -= 1;
										}
									});
								} else if ( k == 'message') {
									$.each(v, function(kk, vv) {
										n_tab2id = vv.id;
										var arr = [vv.rname, vv.content,vv.stime];
										var gotourl = srcurl + "admin/khly";
										if (n_tab2 <= max_lines) {
											addline($("#tab2"), arr, gotourl);
											n_tab2 += 1;
										} else {
											delline($("#tab2 table"), 1);
											n_tab2 -= 1;
										}
									});
								} /*else if ( k == 'list') {
									$.each(v, function(kk, vv) {
										n_tab3id = vv.id;
										var arr = [vv.operatorname, vv.ordernum, vv.opttime];
										var gotourl = srcurl + "count/ddgltj";
										if (n_tab3 <= max_lines) {
											addline($("#tab3"), arr, gotourl);
											n_tab3 += 1;
										} else {
											delline($("#tab3 table"), 1);
											n_tab3 -= 1;
										}
									});	
								}*/
							});
						});
			}
			
			$(document).ready(function(){
				$('.tabsel').click(function(){
					var tabid = $(this).attr('tab');
					$('div.tab').each(function(){
						if($(this).attr('id') == tabid) {
							$(this).show();
						}else{
							$(this).hide();						
						}
					});
				});
				
				$('a.hidebtn').click(function(){
					if ( $(this).html() == '显示') {
						$(this).html('隐藏');
						$('div.container').width(400);										
						$('div.content_info').slideDown('slow');
						$.cookie("infotab", 'true');
					}else{
						$(this).html('显示')
						$('div.content_info').slideToggle('slow');	
						$('div.container').width(150);				
						$.cookie("infotab", 'false');
					}
				});
				
				if ( $.cookie("infotab") == 'false') {
					$('a.hidebtn').html('显示')
					$('div.content_info').slideToggle('slow');	
					$('div.container').width(150);				
				}
				
				$("#div.container").floatdiv();

				infocheck();
				setInterval("infocheck()",6000);
			});
		</script>
		<link rel="stylesheet" type="text/css" href="__PUBLIC__/css/style.css" />
		<style>
.container {
	position:fixed;right:0;bottom:0;
	z-index:9999;
	background-color:#FFF;
	border: 3px solid #E7E7E7;
	padding: 1px;
	width: 400px;
}
.tab {
	width: 384px;
	height: 330px;
	float: left;
	background-color:#FFF;
	margin:0px 2px 2px 2px;
	border:#efefef solid 1px;
	border-top:#CCC solid 2px;
	padding:5px;
	overflow: auto;
}

.tab td {
	padding-left: 10px;
	line-height: 25px;
	border-bottom: 1px solid #f2f2f2;
	color: #000;
}

.tab td a{
	color: #9b0300;
}

.tabsel {
	width: 50px;
	height: 100px;
	background-color: greenyellow;
	float: right;
}
.toolbar {
	background:url(__PUBLIC__/images/headbg.jpg) repeat-x;
	background-color:#CCC;
	color:#666;
	line-height:30px;
	cursor:pointer;
	font-size:12px;
	padding-right:15px;
	font-weight:bold;
	height:30px;
	white-space: nowrap;
	text-align:right;
}
.toolbar a {
	color:#666;
}
.cont_tab { width:400px; height: 27px;
}
.cont_tab a {
	width:80px;
	height:25px;
	float:left;
	background:url(__PUBLIC__/images/ZBG.jpg) repeat-x;
	
	margin:2px 2px 0px 2px;
	line-height:25px;
	font-size:12px;
	text-align:center;
	color:#666;
	cursor:pointer;
}
.cont_tab a:hover {color:#4e89c1;}
</style>
	</head>
	<body>

		<div class="container">
			<div class="toolbar"><span style="color:#0066CC;" id="newsid"></span><a class="hidebtn">隐藏</a></div>
		  <div class="content_info">
  			<div class="cont_tab"> <a class="tabsel" tab='tab1'>订单信息</a> <a class="tabsel" tab='tab2'>留言及退房</a> <!--<a class="tabsel" tab='tab3'>订单处理</a> --></div>
				<div class="tab" id="tab1">
					<table width="100%">
						<tr>
							<td width="50px">房间号</td>
							<td>订单号</td>
							<td>类型</td>
							<td width="120px">时间</td>
						</tr>
					</table>
				</div>
 	 			<div class="tab" id="tab2" style="display:none;">
					<table width="100%">
						<tr>
							<td width="50px">房间号</td>
							<td>类型</td>
							<td width="120px">时间</td>
						</tr>
					</table>
				</div>
 				<!--<div class="tab" id="tab3" style="display:none;">
					<table width="100%">
						<tr>
							<td>房间号</td>
							<td>订单号</td>
							<td>时间</td>
						</tr>
					</table>
				</div>-->
  		</div>
		</div>
	</body>
</html>
